package com.yang.studentsapp.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.eftimoff.patternview.PatternView;
import com.yang.studentsapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ${Ян-Вэнь-Чао} on 2016/9/30.
 */
public class WlcomeActivity extends AppCompatActivity {

    PatternView pattern;
    private String patternString;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//                WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
        setContentView(R.layout.activity_welcome);
        pattern = (PatternView) findViewById(R.id.pattern);
        pattern.setTactileFeedbackEnabled(true);
        Toast.makeText(getApplicationContext(), "ENTER PATTERN", Toast.LENGTH_LONG).show();
        pattern.setPathColor(Color.BLACK);
        pattern.setDotColor(Color.BLACK);
        pattern.setCircleColor(Color.BLUE);
        pattern.setOnPatternDetectedListener(new PatternView.OnPatternDetectedListener() {

            @Override
            public void onPatternDetected() {
                if (patternString == null) {
                    patternString = pattern.getPatternString();
                    return;
                }
                if (!patternString.equals(pattern.getPatternString())) {
                    Toast.makeText(getApplicationContext(), "PATTERN CORRECT", Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(WlcomeActivity.this, LoginActivity.class));
                    pattern.clearPattern();
                    return;
                }
                Toast.makeText(getApplicationContext(), "PATTERN NOT CORRECT", Toast.LENGTH_SHORT).show();
//                patternView.clearPattern();
            }
        });
    }
}
